OPTIONS LINESIZE=80;
TITLE 'ampsimp';


/*
libname libb 'C:\Documents and Settings\yoav\My Documents\school\BigFiles\ampsimple';
libname libS 'C:\Documents and Settings\yoav\My Documents\My Dropbox\work1\AMP\ampsimple\results';
%include 'C:\Documents and Settings\yoav\My Documents\My Dropbox\work1\stasExamples\IATD.sas';
*/

/*

libname libB 'C:\Documents and Settings\user1\My Documents\bigfiles\ampsimple';
libname libS 'C:\Documents and Settings\user1\My Documents\My Dropbox\work\research\att\measure\AMP\amp.studies\ampSimple\results';
%include 'C:\Documents and Settings\user1\My Documents\My Dropbox\work\resources\stasExamples\IATD.sas';

*/

/*thinkpad
libname libS 'D:\Users\baranany\Dropbox\work\research\att\measure\AMP\amp.studies\ampSimple\results';
libname libB 'D:\Users\baranany\Documents\bigfiles\ampintnt';
%include 'D:\Users\baranany\Dropbox\work1\stasExamples\IATD.sas';
*/

/*Learn about the session*/
/*session ids after 1741705 belonged to another study*/
data ssds; set libB.sessiontasks1800000; subject = SESSION_ID; where session_id<1741705; run;
proc freq data=ssds; tables session_date; run;
/*proc freq data=ssds; tables TASK_ID_S; run;*/
/*proc freq data=ssds; tables TASK_URL_S; where session_date > '1Dec2007:20:45:00'dt; RUN;*/
proc freq data=ssds; tables TASK_ID_S; run;
PROC SORT DATA=ssds; BY subject TASK_ID_S; RUN;
PROC UNIVARIATE DATA=ssds NOPRINT;
VAR TASK_NUMBER;OUTPUT OUT=usession mean=mNum mode=tNum;BY subject TASK_ID_S;RUN;
PROC TRANSPOSE DATA=usession OUT=orderDS prefix=ord;VAR TASK_ID_S;ID tNum;BY subject;RUN;
data orderDS; set orderDS; 
orderall = trim(ord2) || "-" || trim(ord3) || "-" || trim(ord4) || "-" ||  trim(ord5) || 
"-" ||  trim(ord6) || "-" ||  trim(ord7) || "-" ||  trim(ord8) || "-" ||  trim(ord9); run;
proc freq data=orderDS; tables orderall / nocum; run;
proc freq data=orderDS; tables ord9; run;
data libB.orderds; set orderds;run;
/*proc freq data=orderDS; tables ord14; run;*/

/********************************************/


data ds; set libB.iats1800000; where session_id<1741705; run;
proc freq data=ds; tables task_name_s; run;
/*AMP*/
data foramp; set ds; where task_name_s in ("amprace" "amppltc"); run;
proc freq data=foramp; tables trial_name_s; run;
DATA foramp; SET foramp;

	target = '12345678912345678'; prime = '123456789123456789'; trgt = 'abc'; prm = '1234';

	target = substr(TRIAL_NAME_S, index(TRIAL_NAME_S, "<"), 
		index(TRIAL_NAME_S, ">") - index(TRIAL_NAME_S, "<") + 1);
	trgt = substr(target, index(target, "<")+4, index(target, ".") - index(target, "<"));

	prime = substr(TRIAL_NAME_S, index(TRIAL_NAME_S, "[")+1, 
			index(TRIAL_NAME_S, ".") - index(TRIAL_NAME_S, "[") - 1);
	*set cond;
	if (index(prime, "Grey") > 0) then prm = "gry";
	else if (index(prime, "white") > 0) then prm = "wht";
	else if (index(prime, "black") > 0) then prm = "blk";
	else if (index(prime, "bclnt") > 0) then prm = "dem";
	else if (index(prime, "hclnt") > 0) then prm = "dem";
	else if (index(prime, "obm") > 0) then prm = "dem";
	else if (index(prime, "bsh1") > 0) then prm = "rep";
	else if (index(prime, "bsh2") > 0) then prm = "rep";
	else if (index(prime, "rgn") > 0) then prm = "rep";
	else delete;

	*set reponse;
	if TRIAL_RESPONSE_S eq "Pleasant" then do; plsnt = 1; end;
	else if TRIAL_RESPONSE_S eq "Unpleasant" then do; plsnt = 0; end;

	subject = SESSION_ID;
run;
proc freq data=foramp; tables prm; run;

/*score*/
/*
%include 'C:\Documents and Settings\yoav\My Documents\school\workn\work1\stasExamples\score\scoreMac.sas';
%include 'C:\Documents and Settings\yoav\My Documents\school\workn\work1\stasExamples\score\excludeMac.sas';
%include 'C:\Documents and Settings\yoav\My Documents\school\workn\work1\stasExamples\score\getsidexc.sas';
*/
%include 'C:\Documents and Settings\user1\My Documents\My Dropbox\work\resources\stasExamples\score\scoreMac.sas';
%include 'C:\Documents and Settings\user1\My Documents\My Dropbox\work\resources\stasExamples\score\excludeMac.sas';
%include 'C:\Documents and Settings\user1\My Documents\My Dropbox\work\resources\stasExamples\score\getsidexc.sas';
%include 'C:\Documents and Settings\yoav\My Documents\My Dropbox\work1\stasExamples\score\scoreMac.sas';
%include 'C:\Documents and Settings\yoav\My Documents\My Dropbox\work1\stasExamples\score\excludeMac.sas';
%include 'C:\Documents and Settings\yoav\My Documents\My Dropbox\work1\stasExamples\score\getsidexc.sas';
%include 'D:\Users\baranany\Dropbox\work1\stasExamples\score\scoreMac.sas';
%include 'D:\Users\baranany\Dropbox\work1\stasExamples\score\excludeMac.sas';
%include 'D:\Users\baranany\Dropbox\work1\stasExamples\score\getsidexc.sas';


%ampScore(libIn=work, libOut=libb, indata=foramp, outdata=amp, SUBJECT=session_id, TRIAL_COND=prm, 
trlResp=plsnt, parcelVar=block_number, prefix=amp, debug=1);
proc print data=libb.amp;run;

/*AMP response bias*/
PROC SORT DATA=foramp; BY session_id block_number trial_number; RUN;
data forampex; set foramp; sameRsp =  (trial_number ne 0) and (plsnt=lag(plsnt));run;
/*proc print data=forampex;var session_id block_number trial_number plsnt sameRsp; run;*/
PROC MEANS DATA=forampex n MEAN MAXDEC=2 fw=7 std stderr noprint;
VAR sameRsp;CLASS subject; output out=ampAlt mean=sameRsp; RUN;
data ampAlt; set ampAlt; nAMPs = _freq_; keep subject nAMPs sameRsp;run;
/*proc print data=ampalt;run;*/
proc freq data=ampalt; tables sameRsp; run;
data libb.ampalt; set ampalt;run;

/*The IAT*/
/*read IAT*/
proc freq data=ds; tables TASK_NAME_S; run;
data forIAT; set ds; if BLOCK_NUMBER in (2 3 5 6) and substr(TASK_NAME_S,1,1) = 'i';run;
proc freq data=foriat; tables BLOCK_PAIRING_DEFINITION_S; run;
data forIAT;set forIAT;
BLOCK='..';
if index(BLOCK_PAIRING_DEFINITION_S,'White People/Good') > 0 or index(BLOCK_PAIRING_DEFINITION_S,'Democrtas/Good') > 0 then do;
	if BLOCK_number in (2 5) then BLOCK = 'B3'; else BLOCK = "B4"; end;
else if index(BLOCK_PAIRING_DEFINITION_S,'Black People/Good') > 0 or index(BLOCK_PAIRING_DEFINITION_S,'Republicans/Good') > 0 then do;
	if BLOCK_number in (2 5) then BLOCK = 'B6'; else BLOCK = "B7"; end;
TRIAL_ERR = input(TRIAL_ERROR,4.0);
run;
proc freq data=forIAT; tables block; run;
*call SAS macro - rules defined and summarized in the Macro explanation script;
%iatCalc(work, work, forIAT, iat, BLOCK, SESSION_ID, TRIAL_LATENCY, TRIAL_ERR, 2, 2, 1);
/**IAT1= B6-B3, IAT2 = B7-B4; so it is preference for snakes*/
data iat; set iat; subject = SESSION_ID; 
keep subject SESSION_ID IAT IAT1 IAT2 MB3 MB6 EB3 EB6 NB3 NB6 FB3 FB6
MB4 MB7 EB4 EB7 NB4 NB7 FB4 FB7 subexcl; run; 
PROC MEANS DATA=iat n MEAN MAXDEC=2 min max std stderr fw=7;
VAR IAT1 IAT2 IAT mb3 mb4 mb6 mb7;RUN;
data libB.iat; set iat; run; 

/*read explicit*/
proc freq data=libB.explicits1800000; tables QUESTIONNAIRE_NAME_S; where session_id<1741705; run;
data eds; set libB.explicits1800000;if QUESTIONNAIRE_NAME_S in ("exprace" "lngrace" "raterace" "exppltc" "lngpltc" "ratepltc"); where session_id<1741705; run;
proc freq data=eds; tables QUESTION_NAME_S;run;
data eExp; set eds;
subject=SESSION_ID; 
expR = INPUT(QUESTION_RESPONSE_S, 4.0); 
qst = QUESTION_NAME_S; qstr = QUESTIONNAIRE_NAME_S;
qstN = QUESTION_NUMBER;
keep subject TASK_NUMBER SESSION_ID qst qstr qstN expR; run;
proc sort data=eexp;by session_id;run;
PROC TRANSPOSE DATA=eexp OUT=exp;VAR expR;BY session_id;ID qst;RUN;
proc contents short data=exp;run;
PROC MEANS DATA=exp n MEAN MAXDEC=2 fw=7 std stderr;VAR  eBlack eDems eReps eWhite infl intent read b1 b2 b3 w1 w2 w3 r1 r2 r3 d1 d2 d3;RUN;
data libb.exp; set exp; run;
/*Read duration*/
data startT; set ssds; if TASK_ID_S = "con"; startT = TASK_CREATION_DATE; run;
data endT; set ssds; if TASK_ID_S = "dbrf"; endT = TASK_CREATION_DATE; run;
PROC SORT DATA=startT; BY SESSION_ID; RUN;
PROC SORT DATA=endT; BY SESSION_ID; RUN;
data timeds; merge startT endT; by SESSION_ID; duration = endT - startT; run;
proc freq data=timeds; tables duration; run;
data libb.timeds; set timeds;run;

*****************************;
*add data from registration;
data demo; set libB.demos; run;
proc sort data=demo; by USER_ID;run;
proc transpose data=demo name=name out=demoDS; by USER_ID; var VALUE_S;id CHARACTERISTIC_S;
/*proc print data=demoDS;run;*/
data demoDS; set demoDS; 
format dPlt 2.;
dPlt = politicalid;
age = 2007-input(birthyear,4.0);
orgn = citizenship;
race='.....';
if raceomb=1 then race='ntvAm';
if raceomb=2 then race='eAsia';
if raceomb=3 then race='sAsia';
if raceomb=4 then race='natPc';
if raceomb=5 then race='black';
if raceomb=6 then race='white';
if raceomb=7 then race='blkwh';
if raceomb=8 then race='mixed';
if raceomb=9 then race='unkno';
sex = substr(sex, 1,1);
keep dPlt sex age orgn race USER_ID;run;
/*proc print data=demoDS;run;*/
*merge with session data;
data ssds; set libB.sessiontasks1800000; where session_id<1741705; run;
/*proc print data=ssds; var session_id session_date; run;
proc freq data=ssds; tables task_id_s; run;*/
proc contents short data=ssds; run;

PROC SORT DATA=ssds; BY SESSION_ID; RUN;
PROC TRANSPOSE DATA=ssds OUT=tss PREFIX=s;VAR USER_ID;BY SESSION_ID; RUN;
data tss; set tss; USER_ID = s1; keep SESSION_ID USER_ID; run;
/*proc print data=tss;run;*/
PROC SORT DATA=demoDS; BY USER_ID; RUN;
PROC SORT DATA=tss; BY USER_ID; RUN;
data demoDS; merge demoDS tss; by USER_ID; drop _NAME_; run;
data demoDS; set demoDS; where SESSION_ID > 0; subject = SESSION_ID; run;
/*proc print data=demoDS;run;*/
data libB.demoDS; set demoDS;run;

/*merge all*/
data orderDS; set libB.orderDS; run;
data iat; set libB.iat; run;
data demods; set libB.demods; run;
data amp; set libB.amp; subject = session_id;run;
data ampalt; set libB.ampalt; run;
data timeds; set libB.timeds; subject = session_id;run;
data exp; set libb.exp; subject=session_id; run;

PROC SORT DATA=orderDS; BY subject; RUN;
PROC SORT DATA=iat; BY subject; RUN;
PROC SORT DATA=amp; BY subject; RUN;
PROC SORT DATA=ampalt; BY subject; RUN;
PROC SORT DATA=timeds; BY subject; RUN;
PROC SORT DATA=exp; BY subject; RUN;
PROC SORT DATA=demods; BY subject; RUN;

data allds; run;
data allds; merge orderDS iat amp ampalt timeds exp demods; by subject; run;

proc contents short data=allds; run;
/*
EB3 EB4 EB6 EB7 FB3 FB4 FB6 FB7 IAT IAT1 IAT2 MB3 MB4 MB6 MB7 NB3 NB4 NB6 NB7
SESSION_CREATED_BY SESSION_CREATION_DATE SESSION_DATE SESSION_ID
SESSION_LAST_UPDATE_DATE SESSION_STATUS STUDY_NAME STUDY_URL_S SUBEXCL
TASK_CREATION_DATE TASK_ID_S TASK_NUMBER TASK_URL_S USER_AGENT_S USER_ID _NAME_
age amp_tblk amp_tblk1 amp_tblk2 amp_tdem amp_tdem1 amp_tdem2 amp_tgry amp_tgry1
amp_tgry2 amp_trep amp_trep1 amp_trep2 amp_twht amp_twht1 amp_twht2 dPlt
duration eBlack eDems eReps eWhite endT infl intent nAMPs name ord0 ord1 ord2
ord3 ord4 ord5 ord6 ord7 ord8 ord9 ord10 orderall orgn race read sameRsp sex
startT subject
*/

proc freq data=allds; tables ord3; run;
data allds; set allds; 
ampWhtBlk = amp_twht-amp_tblk; ampWhtBlk1 = amp_twht1-amp_tblk1; ampWhtBlk2 = amp_twht2-amp_tblk2; 
ampBlkGry = amp_tblk-amp_tgry;  ampWhtGry = amp_twht-amp_tgry; 
abs_ampWhtBlk = abs(ampWhtBlk); abs_ampWhtGry = abs(ampWhtGry); abs_ampBlkGry = abs(ampBlkGry); 
abs_raceGry = mean(abs_ampWhtGry, abs_ampBlkGry);

ampdemrep = amp_tdem-amp_trep; ampdemrep1 = amp_tdem1-amp_trep1; ampdemrep2 = amp_tdem2-amp_trep2; 
ampRepGry = amp_tRep-amp_tgry;  ampDemGry = amp_tDem-amp_tgry; 
abs_ampDemRep = abs(ampDemRep); abs_ampDemGry = abs(ampDemGry); abs_ampRepGry = abs(ampRepGry); 
abs_pltcGry = mean(abs_ampDemGry, abs_ampRepGry);

itmwht = mean(w1, w2, w3); itmblk = mean(b1, b2, b3); itmDem = mean(d1, d2, d3); itmRep = mean(r1, r2, r3);
itmWhtBlk = itmWht-itmBlk; itmDemRep = itmDem-itmRep; 
itmok = (w1 ^=. and w2 ^=. and w3 ^=. and b1 ^=. and b2 ^=. and b3 ^=.) or (d1 ^=. and d2 ^=. and d3 ^=. and r1 ^=. and r2 ^=. and r3 ^=.); 
itm = mean(itmWhtBlk, itmDemRep);

if ord3="amppltc" then do; iatDemRep = iat; study="pltc"; end;
else if ord3="amprace" then do; iatWhtBlk = iat; study="race"; end;

mamp = mean(amp_twht, amp_tblk, amp_tgry, amp_tdem, amp_trep);
ampok = mamp not in (0 1) and read=1; iatok = (subexcl=0); 
eWhtBlk = eWhite-eBlack; eDemRep = eDems-eReps;
explicit = mean(eWhtBlk, eDemRep);

amp = mean(ampWhtBlk, ampDemRep); amp1 = mean(ampWhtBlk1, ampDemRep1); amp2 = mean(ampWhtBlk2, ampDemRep2);

allmsr = (amp ^= . and iat ^= . and explicit ^= . and itmok=1);
allok = (ampok and iatok and allmsr);
if ampok = 1 then amp_ok=amp;
abs_amp_ok = abs(amp_ok); 

abs_ewhtblk = abs(ewhtblk); abs_iatwhtblk = abs(iatwhtblk); abs_itmwhtblk = abs(itmwhtblk);
abs_edemrep = abs(edemrep); abs_iatdemrep = abs(iatdemrep); abs_itmdemrep = abs(itmdemrep);

intentXamp1 = intent*amp1; intentXamp = intent*amp;
inflXamp1 = infl*amp1; inflXamp = infl*amp;

intnt=intent; if intent in (1 2) then intnt=1.5;
intntXamp1 = intnt*amp1; intntXamp = intnt*amp;

drop _NAME_ _TYPE_;
run;
data libs.amps; set allds; run;
data allds; set libs.amps; run;

proc freq data=allds; tables study; where allmsr=1; run;
/*RACE study*/
proc freq data=allds; tables mamp; where allmsr=1 and study="race"; run;
proc freq data=allds; tables read; where allmsr=1 and study="race"; run;
proc freq data=allds; tables iatok; where allmsr=1 and study="race"; run;
proc freq data=allds; tables allok; where allmsr=1 and study="race"; run;
proc freq data=allds; tables sex; where study="race" and allmsr=1 ; run;
proc freq data=allds; tables race; where study="race" and allmsr=1 ; run;
PROC MEANS DATA=allds n MEAN MAXDEC=2 fw=7 std stderr;
VAR age;CLASS study; where allmsr=1; RUN;
proc freq data=allds; tables sex; where study="pltc" and allmsr=1 ; run;
proc freq data=allds; tables race; where study="pltc" and allmsr=1 ; run;

/*Politics study*/
proc freq data=allds; tables mamp; where allmsr=1 and study="pltc"; run;
proc freq data=allds; tables read; where allmsr=1 and study="pltc"; run;
proc freq data=allds; tables iatok; where allmsr=1 and study="pltc"; run;
proc freq data=allds; tables allok; where allmsr=1 and study="pltc"; run;
/*Means*/
ods html close; ods html file="C:\tmp.htm" style=normal;
PROC MEANS DATA=allds n MEAN MAXDEC=2 fw=7 std stderr t prt;var ampwhtblk ewhtblk iatwhtblk  itmwhtblk; where allok=1;run;
PROC MEANS DATA=allds n MEAN MAXDEC=2 fw=7 std stderr t prt;var ampdemrep edemrep iatdemrep  itmdemrep; where allok=1;run;
ods html close;

/*Basic intercorrelations*/
ods html close; ods html file="C:\tmp.htm" style=normal;
proc corr data=allds;  var ampwhtblk iatwhtblk ewhtblk itmwhtblk; where allok=1;run;
proc corr data=allds;  var ampdemrep iatdemrep edemrep itmdemrep; where allok=1;run;
ods html close;
/*Moderation by RPE, race*/
ods html close; ods html file="C:\tmp.htm" style=normal;
proc freq data=allds; tables infl; where study="race" and allok=1; run;
proc corr data=allds;  var abs_raceGry; with infl; where allok=1;run;
PROC MEANS DATA=allds n MEAN MAXDEC=2 fw=7 std stderr t prt; VAR ampWhtBlk abs_raceGry; class infl; where allok=1; run;
PROC SORT DATA=allds; BY infl; RUN;
proc corr data=allds nosimple;  var ampwhtblk1 ampwhtblk2; by infl; where allok=1; run;
proc corr data=allds nosimple;  var ampwhtblk; with ewhtblk itmWhtBlk iatWhtBlk; by infl; where allok=1; run;
PROC SORT DATA=allds; BY infl; RUN;
proc corr data=allds nosimple;  var ewhtblk; with iatWhtBlk; by infl; where allok=1; run;
ods html close;
PROC MEANS DATA=allds n MEAN MAXDEC=2 fw=7 std stderr t prt; VAR ampWhtBlk abs_raceGry; class infl; 
where allok=1 and infl in (1 -1); run;
proc ttest data=allds; var abs_raceGry;class infl; where allok=1 and infl in (1 2) and study="race"; run;

/*Moderation by RPE, politics*/
ods html close; ods html file="C:\tmp.htm" style=normal;
proc freq data=allds; tables infl; where study="pltc" and allok=1; run;
PROC MEANS DATA=allds n MEAN MAXDEC=2 fw=7 std stderr t prt; VAR ampDemRep abs_pltcGry; class infl; where allok=1; run;
proc corr data=allds nosimple;  var abs_pltcGry; with infl; where allok=1; run;
PROC SORT DATA=allds; BY infl; RUN;
proc corr data=allds nosimple;  var ampDemRep1 ampDemRep2; by infl; where allok=1; run;
proc corr data=allds nosimple;  var ampDemRep; with eDemRep itmDemRep iatDemRep; by infl; where allok=1; run;
proc corr data=allds nosimple;  var eDemRep; with iatDemRep; by infl; where allok=1; run;
ods html close;
proc ttest data=allds; var abs_pltcGry;class infl; 
where allok=1 and infl in (2 -1) and study="pltc"; run;

/*modertaion by reported intention, race*/
ods html close; ods html file="C:\tmp.htm" style=normal;
proc freq data=allds; tables intent; where study="race" and allok=1; run;
proc corr data=allds;  var abs_raceGry; with intent; where allok=1;run;
PROC MEANS DATA=allds n MEAN MAXDEC=2 fw=7 std stderr t prt; VAR ampWhtBlk abs_raceGry; class intent; where allok=1; run;
PROC SORT DATA=allds; BY intent; RUN;
proc corr data=allds nosimple;  var ampwhtblk1 ampwhtblk2; by intent; where allok=1; run;
proc corr data=allds nosimple;  var ampwhtblk; with ewhtblk itmWhtBlk iatWhtBlk; by intent; where allok=1; run;
proc corr data=allds nosimple;  var iatWhtBlk; with ewhtblk; by intent; where allok=1; run;
ods html close;
/*TABLE 4*/
proc corr data=allds nosimple;  with ampwhtblk ampwhtblk1 iatWhtBlk; var ewhtblk itmWhtBlk iatWhtBlk ampwhtblk2; where allok=1 and (intent=-2 or infl<0); run;
proc corr data=allds nosimple;  with ampwhtblk ampwhtblk1 iatWhtBlk; var ewhtblk itmWhtBlk iatWhtBlk ampwhtblk2; where allok=1 and (intent>-2 and infl>=0); run;
/*Moderation by reported intention, politics*/
ods html close; ods html file="C:\tmp.htm" style=normal;
proc freq data=allds; tables intent; where study="pltc" and allok=1; run;
PROC MEANS DATA=allds n MEAN MAXDEC=2 fw=7 std stderr t prt; VAR ampDemRep abs_pltcGry; class intent; where allok=1; run;
PROC SORT DATA=allds; BY intent; RUN;
proc corr data=allds nosimple;  var ampDemRep1 ampDemRep2; by intent; where allok=1; run;
proc corr data=allds nosimple;  var ampDemRep; with eDemRep itmDemRep iatDemRep; by intent; where allok=1; run;
proc corr data=allds nosimple;  var iatDemRep; with eDemRep; by intent; where allok=1; run;
ods html close;
/*TABLE 4*/
proc corr data=allds nosimple; with ampdemrep iatDemRep ampdemrep1; var edemrep itmdemrep iatdemrep ampdemrep2; where allok=1 and (intent=-2 or infl<0); run;
proc corr data=allds nosimple; with ampdemrep iatDemRep ampdemrep1; var edemrep itmdemrep iatdemrep ampdemrep2; where allok=1 and (intent>-2 and infl>=0); run;

/*PSPB REVISION 18/JAN/2012*/
**internal consistency;
data allds; set allds;
itmwhtblk1 = w1-b1; itmwhtblk2 = w2-b2; itmwhtblk3 = w3-b3; 
itmdemrep1 = d1-r1; itmdemrep2 = d2-r2; itmdemrep3 = d3-r3; 
run;
proc corr alpha data=allds;  var ampDemRep1 ampDemRep2; where allok=1; run;
proc corr alpha data=allds;  var ampWhtBlk1 ampWhtBlk2; where allok=1; run;
PROC SORT DATA=allds; BY study; RUN;
proc corr alpha data=allds;  var iat1 iat2; where allok=1; by study; run;
proc corr alpha data=allds;  var itmwhtblk1 itmwhtblk2 itmwhtblk3; where allok=1; run;
proc corr alpha data=allds;  var itmdemrep1 itmdemrep2 itmdemrep3; where allok=1; run;
